#!/bin/bash
# make_saf - make small and fast serial, automates make calls for "small and fast" projects
# Bug: Wave files must be relative! -> readlink -f
# Erweitern: liest bis zu $NUM_FILES gleichzeitig ein

(( $# < 3 )) && { echo "make_saf <projectdir> <makecommand> <file1.wav> [file2.wav] ..."; exit 1; }

#set -x
train='traindata'
currdir=`pwd`
projectdir=`pwd`/"$1"; shift
makecommand="$1"; shift

make -s cleantemp

for file
do
	filewav=`echo "$currdir/$file"`
	filetxt=`echo "$currdir/$file" | sed 's/.wav$/.txt/'`
	cd "$projectdir/$train"
	ln -s "$filetxt" .
	ln -s "$filewav" .
	cd "$projectdir"
	make -s "$makecommand"
	rm -f "$train"/*.wav "$train"/*.txt 'code.scp' 'gram' 'dict.0' 'wlist'
done
